package com.neulogistics.core.substation.domain.model.aggregate;

import com.neulogistics.core.substation.domain.model.enumeration.TaskStatus;
import com.neulogistics.core.substation.domain.model.enumeration.TaskType;
import com.neulogistics.core.substation.domain.model.valueobject.CourierInfo;
import com.neulogistics.core.substation.domain.model.valueobject.CustomInfo;
import com.neulogistics.core.substation.domain.model.valueobject.OrderInfo;
import com.neulogistics.infrastructure.ddd.domain.seedwork.Entity;
import com.neulogistics.infrastructure.ddd.domain.seedwork.IAggregateRoot;
import lombok.Data;

import java.util.Date;

@Data
public class TaskOrder extends Entity<Long> implements IAggregateRoot {
    /**
     * 任务单id
     */
    private Long taskId;

    /**
     * 任务类型：1:送货收款；2:退货；3:换货
     */
    private TaskType taskType;

    /**
     * 任务状态：0:待货；1:待分配；2:待领货；3:待配送；4:已完成
     */
    private TaskStatus taskStatus;

    /**
     * 所属分站id
     */
    private Integer substationId;

    /**
     * 关联订单信息，{订单id、订单项、总额、备注、收货地址、收货人名、收货人电话、发票需求、期望配送时间}
     */
    private OrderInfo orderInfo;

    /**
     * 订单客户信息，{客户id、客户名、客户电话}
     */
    private CustomInfo customInfo;

    /**
     * 配送员{userId，name}
     */
    private CourierInfo courierInfo;

    /**
     * 备注
     */
    private String taskRemark;

    /**
     * 发票号
     */
    private Long invoiceId;

    /**
     * 用户满意度
     */
    private Integer customSatisfaction;

    /**
     * 用户评价
     */
    private String customEvaluation;

    /**
     * 创建时间
     */
    private Date createTime;

    /**
     * 完成时间
     */
    private Date completeTime;

    /**
     * 更新时间
     */
    private Date updateTime;

    /**
     * 是否删除
     */
    private Integer deleted;

    public TaskOrder() {
    }

    public TaskOrder(Long taskId, TaskType taskType, Integer substationId,
                     OrderInfo orderInfo, CustomInfo customInfo,
                     String taskRemark) {
        this.taskId = taskId;
        this.taskType = taskType;
        this.taskStatus =
                taskType == TaskType.Return ? TaskStatus.To_Be_Assigned : TaskStatus.To_Be_Shipped;
        this.substationId = substationId;
        this.orderInfo = orderInfo;
        this.customInfo = customInfo;
        this.taskRemark = taskRemark;
    }
}
